//
//  PresentSimpleRedViewController.m
//  UIViewControllerTransitionDemo
//
//  Created by Guo Rui on 2017/7/3.
//  Copyright © 2017年 GR Harry. All rights reserved.
//

#import "PresentSimpleRedViewController.h"
#import "PresentSimpleAnimator.h"

@interface PresentSimpleRedViewController ()<UIViewControllerTransitioningDelegate>

@end

@implementation PresentSimpleRedViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor redColor];
    
    UIButton *dismissButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [dismissButton setTitle:@"Dissmiss" forState:UIControlStateNormal];
    [dismissButton addTarget:self action:@selector(dismissAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:dismissButton];
    
    [dismissButton sizeToFit];
    dismissButton.center = self.view.center;
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    NSLog(@"viewWillAppear");
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    NSLog(@"viewDidAppear");
}

- (void)dismissAction {
    self.transitioningDelegate = self;
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
    return [[PresentSimpleAnimator alloc] initWithDismiss:YES];
}


- (void)dealloc {
    
    NSLog(@"\n************\n %@ dealloc \n************", self.class);
}
@end
